#ifndef QBCICONFIG_H
#define QBCICONFIG_H
#include "rapidjson/document.h"
#include <QObject>
namespace bci {

class QBciConfig : public QObject {
  Q_OBJECT
public:
  typedef rapidjson::GenericObject<
      true, rapidjson::GenericValue<rapidjson::UTF8<char>>>
      ConfigObj;

  explicit QBciConfig(QObject *parent = nullptr);

  bool loadFromFile(const QString &filename);
  const ConfigObj getSourceSetting() const { return root["Source"].GetObj(); }
  const ConfigObj getAnalyzerSetting() const {
    return root["Analyzer"].GetObj();
  }
  const ConfigObj getAppSetting() const { return root["App"].GetObj(); }

  const ConfigObj getRootSetting(const QString &name) const {
    return root[name.toStdString().c_str()].GetObj();
  }

  const rapidjson::Document &dom() const { return root; }

private:
  rapidjson::Document root;
};

} // namespace bci
#endif // BCICONFIG_H
